/*
 *@Author: 张楚
 *@Date: 2021-08-03 11:58:54
 *@Description: 使用getx所写的demo
*/
import 'package:flutter/material.dart';
import 'package:totaldemo/getx/getx_demo/search_page1.dart';
import 'package:totaldemo/getx/getx_demo/search_page2.dart';
import 'package:totaldemo/getx/getx_demo/shopitem.dart';
import 'package:totaldemo/utils/btn_widget.dart';
import 'package:get/get.dart';

class GetxHomePage extends StatefulWidget {
  const GetxHomePage({Key key}) : super(key: key);

  @override
  _GetxHomePageState createState() => _GetxHomePageState();
}

class _GetxHomePageState extends State<GetxHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Getxdemo'),
      ),
      body: ListView(
        children: [
          BtnItem(
              content: '搜索框1--不晓得多少年前的老版本',
              callback: () {
                Get.to(() => SearchBarDemo());
              }),
          BtnItem(
              content: '搜索框2',
              callback: () {
                Get.to(() => SearchPage2());
              }),
          BtnItem(
              content: '商品分类界面',
              callback: () {
                Get.to(() => ShopHomePage());
              }),
        ],
      ),
    );
  }

  Widget btnItem({GestureTapCallback callback, String content}) {
    return Container(
      margin: EdgeInsets.only(top: 10, left: 20, right: 20),
      child: Ink(
        decoration: BoxDecoration(
          ///设置渐变
          // gradient: LinearGradient(
          //   // begin: Alignment.topLeft,
          //   // end: Alignment.bottomRight,
          //   // colors: [Color(0xffFFBA13), Color(0xffFFBA13)]
          // ),
          color: Color(0xffFFBA13),
          borderRadius: BorderRadius.circular(20),
        ),
        child: InkWell(
          splashColor: Colors.blue,
          borderRadius: BorderRadius.circular(20),
          onTap: callback,
          child: Container(
            height: 40,
            child: Center(
              child: Text(
                content,
                style: Theme.of(context)
                    .textTheme
                    .headline6
                    .copyWith(fontSize: 15),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
